package com.dmai.capacity.platform.oauth.controller;


import com.dmai.capacity.platform.common.utils.*;
import com.dmai.capacity.platform.oauth.util.RsaTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.*;


@Slf4j
@RestController
@SuppressWarnings("all")
public class OAuth2TestController {

    /**
     * 获取签名
     */
    @RequestMapping(value = "/auth/v1/getSign01")
    public String getSign(@RequestParam(required = false) String code, @RequestParam(required = false) String refresh_token) {
        String privatekey2 = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAyzUoCwfFnZoZWFgL/e8o5x5MXg6FIcs1DTncmHGAjwrrLsGGkNPFiaL+jb0EG145qvGQ9TSmXJZdhTfjkTAO9QIDAQABAkBaW/rAXOZc3Gckx5IdirlvfCONN3uvuUKP7QjQqLf34qIgYJvhm7Wn7ePIhcw41pxo/V/dzUCzEEGmDgDcsYMJAiEA6r0EadUks1Fw7LzQFCc3zqcm1Ke8ikkP/zPv9MiyoPMCIQDdnQXLI99bjmlPO/Xfm9uY/yxTGxavMo+n//BcLhtKdwIgDhDLbegGrfQIVzctJLgA4RIlAoMWiha8racYDsvj4D8CIQCUyhUWs2oGDZJ06TwGOp1wlnpK/df4HslGsVbOfQJDtwIgLoSsA5X0YJw/+8rrbA1mdOFQUaSNVcZK6iFwXG7N4xM=";
        String sign = "";

        if (StringUtil.isNotEmpty(code)) {
            Map<String, String> dataMap = new HashMap<>();
            dataMap.put("client_id", "00000001");
            dataMap.put("grant_type", "authorization_code");
            dataMap.put("code", code);
            Map<String, String> dataMap1 = new HashMap<>();

            sign = RsaTools.getRsaSign(privatekey2, dataMap);
        } else if (StringUtil.isNotEmpty(refresh_token)) {
            Map<String, String> dataMap2 = new HashMap<>();
            dataMap2.put("client_id", "00000001");
            dataMap2.put("grant_type", "refresh_token");
            dataMap2.put("refresh_token", refresh_token);

            sign = RsaTools.getRsaSign(privatekey2, dataMap2);
        }
        return sign;
    }

    /**
     * 获取签名
     */
    @RequestMapping(value = "/auth/v1/getSign98")
    public String getSign98(@RequestParam(required = false) String code, @RequestParam(required = false) String refresh_token) {
        String privatekey2 = "MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEArSnp0EZSXKnYWs1XNVTJSgi/8Cz4CFL9Y2+NiTniaovFjhgrdbd+7vtKu1rZqmjmviNtFqBxd4/6+b9hN0/DUwIDAQABAkA6rxOgE9ThtmWuEBzX5A37Ww/BE1xTZdydkDaFJOrIdFlG6+PSG7Vq4zJrqwv8xV9IW7bsLVBCa85jg98quZ6hAiEA90OZYUG7I8sRc47ch/nFxz7O9MyWf4TSW8z6X6qhezsCIQCzSBt+UEzE7BKg8aVluZDjQ4r5hhaeej5clWEuGn3myQIge+TtR6Qt5uNrXSGqMp/ej9VS0apphn/A/6qXkbPnsd0CIDK3t29ocA9VaX+2XMAGWwKv3OTyFfwHQRUX/UH5pJxhAiBfSN180JJhEp+8qihon2Pemcj2+vWl8LxlgLgodYSJ3A==";
        String sign = "";

        if (StringUtil.isNotEmpty(code)) {
            Map<String, String> dataMap = new HashMap<>();
            dataMap.put("client_id", "57638998");
            dataMap.put("grant_type", "authorization_code");
            dataMap.put("code", code);
            Map<String, String> dataMap1 = new HashMap<>();

            sign = RsaTools.getRsaSign(privatekey2, dataMap);
        } else if (StringUtil.isNotEmpty(refresh_token)) {
            Map<String, String> dataMap2 = new HashMap<>();
            dataMap2.put("client_id", "57638998");
            dataMap2.put("grant_type", "refresh_token");
            dataMap2.put("refresh_token", refresh_token);

            sign = RsaTools.getRsaSign(privatekey2, dataMap2);
        }
        return sign;
    }


    /**
     * 获取签名
     */
    @RequestMapping(value = "/auth/v1/getSign99")
    public String getSign99(@RequestParam(required = false) String code, @RequestParam(required = false) String refresh_token) {
        String privatekey2 = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAvPYu+1K/DE+4av888UiuCBuYC4eq8gX3tFNSxMbmbWWMwU5ABPAe3HKiRLGrt01TzqjOlnH1xTiqz82l8c1UTwIDAQABAkAbInL+rhQ3LV97JenXcCtliKjdxv6aQJcgcvKoxTMjtDkoRVyEBMgn2W6bXzZt+ZEprx7e2fEmsxfWDQ4bEGhBAiEA6cSSvYYOCNcl/UJ0ApsCTGdwGw2XpxlWq+rFAz1N+aECIQDO7ryFpAiEm5Nbn12g6uTaijkYIQ3h9DTyplXprCHn7wIgFGu8mdvFDBanVelhMv0RhVUf4O0eC1XWUWxPy4mmbyECIQCp/JuI/LKynEp0nXmAUvUkQR+dnqmUz9Me8Vzp06kWqQIgOglwzxSAyMc5bKPD9QkvWDIhAd2dixZRXqx7feyfroI=";
        String sign = "";

        if (StringUtil.isNotEmpty(code)) {
            Map<String, String> dataMap = new HashMap<>();
            dataMap.put("client_id", "57638999");
            dataMap.put("grant_type", "authorization_code");
            dataMap.put("code", code);
            Map<String, String> dataMap1 = new HashMap<>();

            sign = RsaTools.getRsaSign(privatekey2, dataMap);
        } else if (StringUtil.isNotEmpty(refresh_token)) {
            Map<String, String> dataMap2 = new HashMap<>();
            dataMap2.put("client_id", "57638999");
            dataMap2.put("grant_type", "refresh_token");
            dataMap2.put("refresh_token", refresh_token);

            sign = RsaTools.getRsaSign(privatekey2, dataMap2);
        }
        return sign;
    }

}
